//
// Created by xili on 2024/8/3 14:41.
// Go big or go home.
//
#include <iostream>
#include <unordered_map>

using namespace std;

class Solution {
public:
    string decodeMessage(string key, string message) {
        unordered_map<char, char> ump;
        int i = 0;
        for (auto &item: key) {
            if (i == 26) {
                break;
            }
            if (!ump.count(item) && isalpha(item)) {
                ump[item] = (char) (i++ + 'a');
            }
        }
        string ans;
        for (auto &item: message) {
            if (isalpha(item)) {
                ans += ump[item];
            } else{
                ans+=' ';
            }
        }
        return ans;
    }
};